//
//  UIControl+ZXCategory.m
//  Runner
//
//  Created by simon on 2020/12/11.
//

#import "UIControl+ZXCategory.h"

@implementation UIControl (ZXCategory)


- (void)zx_buttonExclusiveTouch
{
    self.exclusiveTouch = YES;
}


- (void)zx_setEnabled:(BOOL)enabled disableAlpha:(CGFloat)alpha
{
    self.enabled = enabled;
    if (enabled)
    {
        self.alpha = 1;
    }
    else
    {
        self.alpha = alpha;
    }
}

- (void)zx_setEnabled:(BOOL)enabled backgroundColor:(UIColor *)color disableBackgroundColor:(UIColor *)disableBackgroundColor{
    
    self.enabled = enabled;
    if (enabled)
    {
        self.backgroundColor = color;
    }
    else
    {
        self.backgroundColor = disableBackgroundColor;
    }
}

- (void)zx_setEnabled:(BOOL)enabled borderColor:(UIColor *)color disableBorderColor:(UIColor *)disableBorderColor
{
    self.enabled = enabled;
    if (enabled)
    {
        self.layer.borderColor = [color CGColor];
//        self.layer.borderWidth = 1;
    }
    else
    {
        UIColor *disableColor = disableBorderColor ? disableBorderColor : [UIColor clearColor];
        self.layer.borderColor = [disableColor CGColor];
    }
}
@end
